package com.lrz.controller;

import ch.qos.logback.core.pattern.util.RegularEscapeUtil;
import com.lrz.common.Result;
import com.lrz.pojo.User;
import com.lrz.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;

@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/register")
    public Result register(@RequestBody User user){
        return userService.register(user);
    }

    @GetMapping("/login")
    public Result login(@RequestParam String username, @RequestParam String password){
        return userService.login(username, password);
    }

    @PostMapping("/update")
    public Result update(@RequestBody User user){
        return userService.update(user);
    }

    @GetMapping("/selectUserInfo/{userId}")
    public Result selectUserInfo(@PathVariable Long userId){
        return userService.userInformation(userId);
    }
}
